﻿

''' <summary>
''' 企业运营门户部件页基类
''' 功能：主要处理部件的参数解释、权限判断等公共功能
''' </summary>
''' <remarks>ParamForPass参数格式：门户类型~GUID  其中门户类型统一为：national、firstnav、secondnav 、project</remarks>
Partial Public Class WebPartBasePage
    Inherits Mysoft.Map.Application.Security.AppPage

    Private _PartType As PartType = 0
    ''' <summary>
    ''' 门户类型
    ''' </summary>
    ''' <value>PartType枚举</value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Protected ReadOnly Property PartType() As PartType
        Get
            Return _PartType
        End Get
    End Property
    Private _strGuid As String = ""
    ''' <summary>
    ''' 门户或导航GUID
    ''' </summary>
    ''' <value>GUID字符串</value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Protected ReadOnly Property GUID() As String
        Get
            Return _strGuid
        End Get
    End Property

    Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        '读取页面参数
        Dim strParamForPass As String = GetPageUrl()
        '设置门户类型及GUID
        SetPartTypeAndGUID(strParamForPass)

    End Sub
    ''' <summary>
    ''' 读取页面参数:ParamForPass
    ''' ParamForPass参数格式：门户类型~GUID  其中门户类型统一为：national、firstnav、secondnav 、project
    ''' </summary>
    ''' <returns>字符串</returns>
    ''' <remarks></remarks>
    Private Function GetPageUrl() As String
        '读取页面参数
        Dim strParamForPass As String = [Public].Utility.GetQueryString("ParamForPass", String.Empty)
        If strParamForPass = String.Empty Or 0 >= strParamForPass.IndexOf("~") Then
            Throw New Exception("参数格式错误，请与管理员联系！")
        End If
        Return strParamForPass
    End Function
    ''' <summary>
    ''' 设置门户类型及GUID
    ''' </summary>
    ''' <param name="strParamForPass">字符串参数：通过~分隔</param>
    ''' <remarks></remarks>
    Private Sub SetPartTypeAndGUID(ByVal strParamForPass As String)
        Dim arrRequest As String() = strParamForPass.Split("~")
        If arrRequest.Length < 1 Then
            Throw New Exception("参数格式错误，请与管理员联系！")
        Else
            Try
                '读取参数，得到门户的类型
                _PartType = CType([Enum].Parse(GetType(PartType), arrRequest(0).ToLower()), PartType)
                '获取GUID参数
                _strGuid = arrRequest(1)
            Catch ex As Exception
                Throw New Exception("参数格式错误，请与管理员联系！")
            End Try

        End If
    End Sub

End Class


